﻿using System;

class SurfaceOfTriangle
{
    static void TriangleSurface1(double side, double altitude)
    {
        Console.WriteLine("Enter one of the sides of the triangle:");
        side = double.Parse(Console.ReadLine());
        Console.WriteLine("Enter the altitude to this side:");
        altitude = double.Parse(Console.ReadLine());
        double surface = (side * altitude) / 2;
        Console.WriteLine("The surface of this triangle is {0}",surface);
    }
    static void TriangleSurface2(double side1, double side2, double side3)
    {
        Console.WriteLine("Enter the first side of the triangle:");
        side1 = double.Parse(Console.ReadLine());
        Console.WriteLine("Enter the second side of the triangle:");
        side2 = double.Parse(Console.ReadLine());
        Console.WriteLine("Enter the third side of the triangle:");
        side3 = double.Parse(Console.ReadLine());
        double halfPerimeter = (side1 + side2 + side3) / 2;
        double surface = Math.Sqrt(halfPerimeter * (halfPerimeter - side1) * (halfPerimeter - side2) * (halfPerimeter - side3));
        Console.WriteLine("The surface of this triangle is {0}",surface);
    }
    static void TriangleSurface3(double side1, double side2, double angle)
    {
        Console.WriteLine("Enter the first side of the triangle:");
        side1 = double.Parse(Console.ReadLine());
        Console.WriteLine("Enter the second side of the triangle:");
        side2 = double.Parse(Console.ReadLine());
        Console.WriteLine("Enter the angle between this two sides:");
        angle = double.Parse(Console.ReadLine());
        double surface = (side1 * side2 * Math.Sin(Math.PI * angle / 180)) / 2;
        Console.WriteLine("the surface of this triangle is {0}", surface);
    }
    static void Main()
    {
        double side1 = 0;
        double side2 = 0;
        double side3 = 0;
        double angle = 0;
        double altitude = 0;
        Console.WriteLine("Enter the number of the method you want to use to "+
            "calculate the surface of your triangle:");
        Console.WriteLine();
        Console.WriteLine("1. By one given side and an altitude to it;");
        Console.WriteLine("2. By three given sides;");
        Console.WriteLine("3. By two given sides and an angle between them.");
        int choice = int.Parse(Console.ReadLine());
        switch (choice)
        {
            case 1:
                TriangleSurface1(side1, altitude);
                break;
            case 2:
                TriangleSurface2(side1, side2, side3);
                break;
            case 3:
                TriangleSurface3(side1, side2, angle);
                break;
            default:
                Console.WriteLine("Invalid choice!");
                break;

        }

    }
}

